
#include <iostream>
#include <cstdio>
using namespace std;

class A {
	public:
		A( ) { cout << "A( ) is invoked" << endl; }
		~A( ) { cout << "~A( ) is invoked" << endl; }
};

// designer
// ------------------------------------------------------------------
// user

void foo( ) {
	cout << "foo..." << endl;
	A a;
	FILE* pfile =  fopen("./cfg", "r");
	if( !pfile )
		throw -1;
	cout << "foo..." << endl;
}

void bar( ) {
	cout << "bar..." << endl;
	A b;
	try {
		foo( );
	}
	catch ( int e ) {
		cout << "error in bar function" << e << endl;
	}
	cout << "bar..." << endl;
}

void hum( ) {
	cout << "hum..." << endl;
	A c;
	bar( );
	cout << "hum..." << endl;
}

int main( void ) {
	cout << "main..." << endl;
	A d;
	hum( );
	cout << "main..." << endl;

	return 0;
}

